import java.util.Scanner;

/**
 * Created with IntelliJ IDEA.
 * Description: 求最大公约数
 * Author:  LiuTao
 * Version: 1.0
 * Date:    2023-07-30  14:25
 */
public class Test1 {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int a = scanner.nextInt();
        int b = scanner.nextInt();
        while (a % b != 0) {
            int c = a % b;
            a = b;
            b = c;
        }
        System.out.println(b);
    }
}
